package org.eng2.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eng2.model.DBFacade;
import org.eng2.model.FeedbackPratos;


/**
 * Servlet implementation class RelatorioServlet
 */
@WebServlet({"/RelatorioServlet", "/relatorio_pratos"})
public class RelatorioServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RelatorioServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String action = request.getServletPath();
		if (action.equals("/relatorio_pratos")) {
			ExibirFeedbackPratos(request, response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}
	
	private void ExibirFeedbackPratos(HttpServletRequest request,
			HttpServletResponse response)
	{
		System.out.println(DBFacade.getInstance().getAllFeedbackPratos().toString());
		try {
			request.setAttribute("lista_fb", DBFacade.getInstance().getAllFeedbackPratos());
			RequestDispatcher rd = request.getRequestDispatcher("Views/Relatorio/pratos_da_casa.jsp");
			rd.forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
